package com.hxzy.research.controller.adminresearch;

import com.hxzy.research.pojo.ShowCheck1;
import com.hxzy.research.pojo.ShowCheckQq;
import com.hxzy.research.service.pageandmanager.PageBranch;
import com.hxzy.research.service.research.CheckService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

import java.util.List;

/**
 * 教学
 */

@Controller
public class TeacherCheckController {
    @Autowired
    private PageBranch pageBranch;
    @Autowired private CheckService checkService;
    @RequestMapping("/admin/forwardR1List.go")
    public String forwardR1List(Model model)throws Exception{
        //查询分公司列表
        model.addAttribute("branchList",pageBranch.findAllBranch());
        //先跳到点击查询分公司页面
        return "admin/research/r1checkList";
    }
    //根据分公司id和月份查询分公司数据
    @RequestMapping("/admin/getR1List.go")
    public String getR1List(Model model, ShowCheckQq showCheckQq, HttpSession session)throws Exception{
        //查询分公司列表
        session.setAttribute("time",showCheckQq.getMonth());

        model.addAttribute("branchList",pageBranch.findAllBranch());
        List<ShowCheck1> r1list=checkService.findR1ListByMonthAndBranchId(showCheckQq);
        model.addAttribute("r1list",r1list);

        return "admin/research/r1checkList";
    }
    //查询分公司数据de建议
    @RequestMapping("/admin/getR1Suggest.go")
    public String getR1Suggest(Model model,ShowCheckQq showCheckQq,HttpSession session)throws Exception{
        showCheckQq.setMonth((String) session.getAttribute("time"));
        model.addAttribute("suggestList",checkService.findJyList(showCheckQq));
        return "admin/research/r1SuggestView";
    }


    //根据月份查询分公司总体数据
    @RequestMapping("/admin/getAllR1List.go")
    public String getAllR1List(Model model,String month,Integer branchId, HttpSession session)throws Exception{
        //查询分公司列表
        session.setAttribute("time",month);
session.setAttribute("branchid",branchId);
        model.addAttribute("branchList",pageBranch.findAllBranch());
        //查询总体数据
        List<ShowCheck1> r1list=checkService.findAllListByMonth(month);
        model.addAttribute("r1list",r1list);
        return "admin/research/r1AllcheckList";
    }

    //查询分公司总体数据de建议
    @RequestMapping("admin/getAllR1Suggest.go")
    public String getAllR1Suggest(Model model,String month,Integer branchId,HttpSession session)throws Exception{
        System.out.println("***************************"+month+"*************"+branchId);
        ShowCheckQq showCheckQq=new ShowCheckQq();
        showCheckQq.setMonth((String) session.getAttribute("time"));
        showCheckQq.setBranchId(branchId);
        System.out.println("————————————————————————————"+(String) session.getAttribute("time"));
        model.addAttribute("suggestList",checkService.findJyAllList(showCheckQq));
        return "admin/research/r1SuggestView";
    }
}
